{extend name="extra@index/base" /}
{block name="title"}我的SpeedUp{/block}

{block name="css"}

{/block}


{block name='page'}
<style>/**页面css写在这里*/
.bar-nav {
    text-align: center;
    color: white;
    background: #0099FF;
}

.icon-right:before {
    float: right;
    padding-right: .75rem;
}

.icon-dizhi:before {
    float: left;
}

.icon-dizhi {
    margin-right: 0.75rem;
    color: #3af;
}
</style>
<!-- 页面开始 -->

<div id="vue">
    <header class="bar bar-nav">
        <h1 class='title' style="color: white">我的</h1>
    </header>
    <div class="content">
        <div class="card-content">
            {php}

            $user=session('user');

            if(!$user['id']){
            {/php}

            <div class="list-block media-list" onclick="$.router.load('/my/index/loginpage');">
                <ul>
                    <li class="item-content">
                        <div class="item-media">
                            <img src="/static/img/avatar.png" width="44">
                        </div>
                        <div class="item-inner">
                            <div class="item-title-row">
                                <div class="item-title">立即登录</div>
                            </div>
                            <div class="item-subtitle">登录后可享受更多特权</div>
                        </div>
                        <span class="icon icon-right"></span>
                    </li>
                </ul>
            </div>


            {php}
            }else{


            $email = $user['mail'];
            $default = "http://speedup.yangyongan.com/static/img/avatar.png";
            $size = 96;
            $grav_url = "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode($default) . "&s=" . $size;

            {/php}

            <div class="list-block media-list" onclick="$.router.load('/my/user/index');">
                <ul>
                    <li class="item-content">
                        <div class="item-media">
                            <img src="{$grav_url}" width="44">
                        </div>
                        <div class="item-inner">
                            <div class="item-title-row">
                                <div class="item-title">{$user['username']}</div>
                            </div>
                            <div class="item-subtitle">{$user['mail']}</div>
                        </div>
                        <span class="icon icon-right"></span>
                    </li>
                </ul>
            </div>


        </div>


        <div class="card" style="margin: .5rem 0">
            <div class="card-content">
                <div class="list-block">
                    <ul>
                        <li>
                            <a href="/my/index/address/" class="item-link item-content" style="padding-left: 0">
                                <div class="item-media"><i class="icon icon-f7"></i></div>
                                <div class="item-inner">
                                    <div class="item-title dizhi"><span class="iconfont icon-dizhi"></span>我的收货地址</div>
                                </div>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>


        <div class="content-block">
            <p><a href="#" class="button button-fill button-warning  button-big" onclick="logout()">退出登录 </a></p>
        </div>


        <script>


            function logout() {

                $.get('/api/my/logout', function (ret) {
                    if (ret.code > 0) {
                        $.toast("退出成功");
                        setTimeout('location.reload()', 2000);
                    }
                })

            }

        </script>


        {php}
        }
        {/php}


    </div>


</div>

<script>

    if (!(document.cookie || navigator.cookieEnabled)) {
        $.alert('cookie 未打开!将不能正常登录注册');
    }


</script>


<!-- 页面结束 -->
{/block}

{block name="base"}

<!-- 左边侧栏开始 -->

<!-- 左边侧栏结束 -->
</div>
{/block}

{block name="js"}
{/block}